import store from "..";
import { useRouter } from 'vue-router'
const router = useRouter()
const menus={
	state:{
			menulist:[],
			permlist:[],
			editableTabsValue: 'Index',
			editableTabs: [{
			  title: '首页',
			  name: 'Index',
			  
			}],
	  },
	mutations:{
		setMenulist:(state,menu)=>{
				 state.menulist=menu	 
			 },
		setPermlist:(state,perm)=>{
			 state.permlist=perm
			},
		addtab(state,tab){
			
			try {
				const index=state.editableTabs.findIndex(e=>e.name===tab.name)
				if(index===-1){
						
						state.editableTabs.push(
						{
							title:tab.title,
							name:tab.name
						}
						);
				}
				
				state.editableTabsValue=tab.name;
			} catch (error) {
			  return 
			}
			
		},
		resetState:(state)=>{
				 state.token=''
				 state.permlist=[]
				 state.editableTabsValue='Index'
				 state.editableTabs=[{
					 title:'首页',
					 name:'Index'
				 }]
		}
		
},
}
export default menus
